package com.hbnu.iostream;

import java.io.*;

/**
 * 需求：通过转换流将内容输出到指定文件中
 *
 * @author kittychen
 * @since 2025-10-11 下午 3:20
 */
public class OutputStreamWriterDemo {
    public static void main(String[] args) {
        String path = "E:" + File.separator + "2310" + File.separator + "class2310.txt";
        File file = new File(path);

        OutputStreamWriter outputStreamWriter = null;
        try {
            outputStreamWriter = new OutputStreamWriter(new FileOutputStream(file, true));
            String content = "今天周六补课";
            outputStreamWriter.write(content);
            System.out.println("写入成功！");
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (outputStreamWriter != null) {
                    outputStreamWriter.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
